package sms4j.dao;

import org.dromara.sms4j.api.dao.SmsDao;

import java.util.concurrent.ConcurrentHashMap;


//最简单的SmsDao实现
public class MySmsDao implements SmsDao {
    {
        System.out.println("加载了自定义实现的SmsDao");
    }
    private static final ConcurrentHashMap<String, Object> DATA_MAP = new ConcurrentHashMap<>();

    @Override
    public void set(String key, Object value, long cacheTime) {
        DATA_MAP.put(key,value);
        System.out.println("使用自定义SmsDao存入信息");
    }

    @Override
    public void set(String key, Object value) {
        this.set(key,value,10000L);
    }

    @Override
    public Object get(String key) {
        System.out.println("使用自定义SmsDao取出信息");
        return DATA_MAP.get(key);
    }

    @Override
    public Object remove(String key) {
        System.out.println("自定义SmsDao移除信息");
        return DATA_MAP.remove(key);
    }

    @Override
    public void clean() {
        System.out.println("清理自定义SmsDao");
        DATA_MAP.clear();
    }
}
